package com.learn.beans.container;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;


/**
 * 2.1 容器的基本用法
 * 《Spring源码深度解析》P10
 */
public class BeanFactoryTest {

	public static void main(String[] args) {
		//容器初始化完 "myTestBean" 就已经注册到容器顺，DefaultSingletonBeanRegistry.addSingleton()方法中打断点查看。
		//ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("test/beanFactory.xml");
		BeanFactory beanFactory = new ClassPathXmlApplicationContext("test/beanFactory.xml");
		//BeanFactory beanFactory = new FileSystemXmlApplicationContext("F:\\code\\spring-framework-analysis\\learn-beans\\src\\main\\resources\\test\\beanFactory.xml");
		MyTestBean bean = (MyTestBean) beanFactory.getBean("myTestBean");
		System.out.println(bean.getTestStr()); //testStr
	}
}
